package com.example.work04;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button button1;
    Button button2;
    Button button3;
    Button button4;
    Button button5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button1 = findViewById(R.id.linear_btn);
        button2 = findViewById(R.id.grid_btn);
        button3 = findViewById(R.id.table_btn);
        button4 = findViewById(R.id.relative_btn);
        button5 = findViewById(R.id.frame_btn);
        setListeners();
    }

    private class  OnClick implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.linear_btn:
                    setContentView(R.layout.linear_layout);
                    break;
                case R.id.grid_btn:
                    setContentView(R.layout.grid_layout);
                    break;
                case R.id.table_btn:
                    setContentView(R.layout.table_layout);
                    break;
                case R.id.relative_btn:
                    setContentView(R.layout.relative_layout);
                    break;
                case R.id.frame_btn:
                    setContentView(R.layout.frame_layout);
                    break;
                default:
                    break;
            }
        }
    }
    private void setListeners(){
        OnClick onClick = new OnClick();
        button1.setOnClickListener(onClick);
        button2.setOnClickListener(onClick);
        button3.setOnClickListener(onClick);
        button4.setOnClickListener(onClick);
        button5.setOnClickListener(onClick);
    }

}